package android.command.gateway;

import java.util.Map;

import android.command.gateway.IGatewayLinux2AndroidCommandResponseObserver;

/**
 * Interface to send a command request from linux to android and receive response of it.
 * {@hide}
 */
interface IGatewayLinux2AndroidCommand {
    /**
     * String constant for the service name.
     */
    const String SERVICE_NAME = "gateway_linux2android_command";

    /**
     * Map key for request id.
     *
     * @see #sendRequest(Map)
     * @see #sendResponse(Map)
     */
    const String KEY_REQUEST_ID = "request_id";

    /**
     * Map key for package name.
     *
     * @see #sendRequest(Map)
     * @see #sendResponse(Map)
     */
    const String KEY_PACKAGE_NAME = "package_name";

    /**
     * Map key for command.
     *
     * @see #sendRequest(Map)
     * @see #sendResponse(Map)
     */
    const String KEY_COMMAND = "command";

    /**
     * Map key for result.
     *
     * @see #sendRequest(Map)
     * @see #sendResponse(Map)
     */
    const String KEY_RESULT = "result";

    /**
     * Map key for show android.
     *
     * @see #sendRequest(Map)
     * @see #sendResponse(Map)
     */
    const String KEY_SHOW_ANDROID = "show_android";

    /**
     * Register the command response observer.
     *
     * @param observer Observer for responses of linux2android commands.
     * {@hide}
     */
    void registerResponseObserver(in IGatewayLinux2AndroidCommandResponseObserver observer);

    /**
     * Unregister the command response observer.
     *
     * @param observer Observer for responses of linux2android commands.
     * {@hide}
     */
    void unregisterResponseObserver(in IGatewayLinux2AndroidCommandResponseObserver observer);

    /**
     * Send a command request from linux to android.
     *
     * @param request Request params in a Map.
     *         Map entries:
     *         <ul>
     *           <li>Key: {@link #KEY_REQUEST_ID}: Id of this request. Value: Type is String.</li>
     *           <li>Key: {@link #KEY_PACKAGE_NAME}: Package name of the android app receiving the command. value: Type is String.</li>
     *           <li>Key: {@link #KEY_COMMAND}: Command in json string. Value: Type is String.</li>
     *         </ul>
     *
     * {@hide}
     */
    void sendRequest(in Map request);

    /**
     * Send a command response from android to linux.
     *
     * @param response Response params in a Map.
     *         Map entries:
     *         <ul>
     *           <li>Key: {@link #KEY_REQUEST_ID}: Id of which request this response responds to. Value: Type is String.</li>
     *           <li>Key: {@link #KEY_RESULT}: Result in json for the command request identified by {@link #KEY_REQUEST_ID}. Value: Type is String.</li>
     *           <li>Key: {@link #KEY_SHOW_ANDROID}: Whether to show android ui. Value: Type is boolean.</li>
     *         </ul>
     *
     * {@hide}
     */
    void sendResponse(in Map response);
}
